//
// Created by Symps on 2025/9/28.
//

#include <iostream>
#include <vector>
using std::endl;
using std::vector;
using std::cout;
using std::string;

vector<vector<int>> generate1(int numRows) {
    vector<vector<int>> ret;
    vector<int> list0;
    list0.push_back(1);
    ret.push_back(list0);
    for (int i = 1; i < numRows; ++i) {
        vector<int> listI;
        listI.push_back(1);
        for (int j = 1; j < i; ++j) {
            listI.push_back(ret[i - 1][j] + ret[i - 1][j - 1]);
        }
        listI.push_back(1);
        ret.push_back(listI);
    }
    return ret;
}

vector<vector<int>> generate2(int numRows) {
    vector<vector<int>> ret;
    ret.resize(numRows);
    for (size_t i = 0; i < numRows; ++i) {
        ret[i].resize(i + 1, 1);
    }
    for (size_t i = 2; i < ret.size(); ++i) {
        if (ret[i].size() > 1) {
            for (size_t j = 1; j < ret[i].size() - 1; ++j) {
                ret[i][j] = ret[i - 1][j - 1] + ret[i - 1][j];
            }
        }
    }
    return ret;
}

void test1() {
    for (auto &row : generate1(5)) {
        for (const auto &col : row) {
            cout << col << " ";
        }
        cout << endl;
    }
    for (auto &row : generate2(5)) {
        for (const auto &col : row) {
            cout << col << " ";
        }
        cout << endl;
    }
}

void print(std::vector<int>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void test2() {
    std::vector v = {1, 2, 3, 4, 5};
    print(v);
    auto it = v.begin();
    cout << *it << endl;
    it = v.erase(it + 2);
    cout << *it << endl;
    print(v);
}

std::string longestPalindrome(std::string s) {
    int n = s.size();
    int maxBegin = 0;
    int maxLen = 0;
    for (int i = 0; i < n; ++i) {
        int left = i - 1, right = i + 1;
        while (right < n && s[i] == s[right]) {
            ++right;
        }
        while (left >= 0 && right < n && s[left] == s[right]) {
            --left;
            ++right;
        }
        int len = right - left - 1;
        if (len > maxLen) {
            maxLen = len;
            maxBegin = left + 1;
        }
    }
    return s.substr(maxBegin, maxLen);
}



int main() {
    // test1();
    // test2();
    return 0;
}